package com.dhcc.core.framework.beetl;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.beetl.core.GroupTemplate;
import org.beetl.core.Template;
import org.beetl.ext.web.WebRenderExt;

import com.dhcc.core.config.properties.SysProperties;
import com.dhcc.core.framework.util.SpringContextHolder;

/**
 * beetl扩展全局属性
 * 
 * @ClassName: BeetlGlobalExt
 * @Description: 描述
 * @author: cyf
 * @date: 2018年1月2日 上午9:46:20
 */
public class BeetlGlobalExt implements WebRenderExt {
    @Override
    public void modify(Template template, GroupTemplate arg1, HttpServletRequest arg2, HttpServletResponse arg3) {
        SysProperties sysProperties = SpringContextHolder.getBean(SysProperties.class);
        template.binding("backendPath", arg2.getContextPath() + sysProperties.getBackendPath());
        template.binding("frontPath", arg2.getContextPath() + sysProperties.getFrontPath());
        template.binding("uriPath", arg2.getRequestURI());
        template.binding("fileMaxSize", sysProperties.getFileUploadMaxSize());
    }
}